package com.example.jikeyoujikeyou.office_sz.service;

import com.example.jikeyoujikeyou.office_sz.model.Company;
import com.example.jikeyoujikeyou.office_sz.model.HttpModel;
import com.example.jikeyoujikeyou.office_sz.model.Staff;

import java.util.HashMap;
import java.util.Map;

public class StaffService extends BaseService {

    public static Staff staff = new Staff();
    public static Company company = new Company();


    /**
     * 登陆
     *
     * @param staff
     */
    public static void login(Staff staff, INetCallBack iNetCallBacks) {
        postData("/user/login", staff, iNetCallBacks);
    }

    /**
     * 获取验证码
     *
     * @param type
     * @param phone
     */
    public static void getCode(int type, String phone, INetCallBack iNetCallBacks) {
        Staff staff = new Staff();
        staff.put("type", type);
        staff.put("phone", phone);
        postData("/user/getCode", staff, iNetCallBacks);
    }

    /**
     * 修改
     *
     * @param phone
     * @param password
     * @param code
     */
    public static void updatePassword(String phone, String password,String code, INetCallBack iNetCallBacks) {
        Staff staff = new Staff();
        staff.setPhone(phone);
        staff.setPassword(password);
        staff.put("code",code);
        postData("/user/upadtePassword", staff, iNetCallBacks);

    }

    /**
     * 注册
     *
     * @param staff
     * @param company
     */
    public static void register(Staff staff, Company company, INetCallBack iNetCallBacks) {
        HashMap<String, Object> map = company.getAttrs();
        for (Map.Entry e : map.entrySet()) {
            staff.put("company_" + e.getKey(), e.getValue());
        }
        postData("/user/register", staff, iNetCallBacks);

    }

}
